load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
load("//bazel:canisters.bzl", "rust_canister")
load("//bazel:defs.bzl", "rust_ic_test")

package(default_visibility = ["//visibility:public"])

rust_library(
    name = "mock",
    srcs = ["src/lib.rs"],
    crate_name = "ic_bitcoin_canister_mock",
    deps = [
        # Keep sorted.
        "@crate_index//:candid",
        "@crate_index//:ic-btc-interface",
        "@crate_index//:serde",
    ],
)

rust_canister(
    name = "bitcoin_canister_mock",
    srcs = ["src/main.rs"],
    crate_name = "ic_bitcoin_canister_mock",
    service_file = "bitcoin_mock.did",
    version = "0.1.0",
    deps = [
        # Keep sorted.
        ":mock",
        "@crate_index//:bech32",
        "@crate_index//:byteorder",
        "@crate_index//:candid",
        "@crate_index//:ic-btc-interface",
        "@crate_index//:ic-cdk",
        "@crate_index//:serde",
        "@crate_index//:serde_bytes",
    ],
)

rust_test(
    name = "mock_tests",
    crate = ":_wasm_bitcoin_canister_mock",
    data = ["bitcoin_mock.did"],
    env = {
        "CARGO_MANIFEST_DIR": "rs/bitcoin/mock",
    },
    deps = [
        "@crate_index//:candid_parser",
    ],
)

rust_ic_test(
    name = "bitcoin_canister_mock_tests",
    srcs = ["tests/tests.rs"],
    data = [
        ":bitcoin_canister_mock",
        "//rs/universal_canister/impl:universal_canister.wasm.gz",
    ],
    env = {
        "CARGO_MANIFEST_DIR": "rs/bitcoin/mock",
        "IC_BITCOIN_CANISTER_MOCK_WASM_PATH": "$(rootpath :bitcoin_canister_mock)",
        "UNIVERSAL_CANISTER_WASM_PATH": "$(rootpath //rs/universal_canister/impl:universal_canister.wasm.gz)",
    },
    deps = [
        # Keep sorted.
        ":mock",
        "//rs/config",
        "//rs/rust_canisters/canister_test",
        "//rs/state_machine_tests",
        "//rs/test_utilities/load_wasm",
        "//rs/types/base_types",
        "//rs/types/types",
        "//rs/universal_canister/lib",
        "@crate_index//:bitcoin",
        "@crate_index//:candid",
        "@crate_index//:candid_parser",
        "@crate_index//:hex",
        "@crate_index//:ic-btc-interface",
        "@crate_index//:ic-cdk",
        "@crate_index//:rand",
    ],
)
